﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Runtime.InteropServices;

namespace AWZhome.NQ.CommonServices.Visual
{
	/// <summary>
	/// Interaktionslogik für PreferenceWindow.xaml
	/// </summary>
	public partial class PreferenceWindow : Window
	{
		[DllImport("user32.dll")]
		private extern static int SetWindowLong(IntPtr hwnd, int index, int value);
		[DllImport("user32.dll")]
		private extern static int GetWindowLong(IntPtr hwnd, int index);

		public PreferenceWindow()
		{
			InitializeComponent();
		}

		protected override void OnSourceInitialized(EventArgs e)
		{
			base.OnSourceInitialized(e);

			// Hide minimize and maximize buttons and the window icon, but let the window be resizable
			const int GWL_STYLE = -16;
			const uint WS_MINIMIZEBOX = 0x00020000;
			const uint WS_MAXIMIZEBOX = 0x00010000;
			const uint WS_SYSMENU = 0x00080000;

			IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
			int value = GetWindowLong(hwnd, GWL_STYLE);

			SetWindowLong(hwnd, GWL_STYLE, (int) (value & ~WS_MINIMIZEBOX & ~WS_MAXIMIZEBOX & ~WS_SYSMENU));
		}
	}
}
